package com.heatingcharge.controller.sys;


import com.heatingcharge.common.util.R;
import com.heatingcharge.entity.sys.SysUserBuilding;
import com.heatingcharge.service.sys.ISysUserBuildingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 收费人区域管理表 前端控制器
 * </p>
 *
 * @author devin.jiang
 * @since 2020-01-12
 */
@RestController
@RequestMapping("/sys-user-building")
public class SysUserBuildingController {

    @Autowired
    ISysUserBuildingService sysUserBuildingService;

    @GetMapping("/buildingIds")
    public R getBuildingIdsByUserId(SysUserBuilding sysUserBuilding){
        List<Integer> menuIdsByRoleId = sysUserBuildingService.getBuildingIdsByUserId(sysUserBuilding);
        return R.ok(menuIdsByRoleId);
    }

    @PostMapping("/{heatYearId}/{userId}")
    public R saveUserBuildings(@PathVariable("heatYearId") Integer heatYearId,
                               @PathVariable("userId") Integer userId,
                               @RequestBody List<Integer> buildingIds){
        Integer result= sysUserBuildingService.saveUserBuildings(heatYearId,userId,buildingIds);
        return R.ok();
    }
}

